EventListeners

Sources

Weiss, Appendix B

Summary

When the user types on the keyboard, or uses the mouse, the operating system produces an event. In Java, there are a few basic rules for using these events:

Example:

public class Beeper ... implements ActionListener {
    ...
    //where initialization occurs:
        button.addActionListener(this);
    ...
    public void actionPerformed(ActionEvent e) {
        ...//Make a beep sound...
    }
}